import java.util.Stack;

public class Text01 {
    class Node {
        public int val;
        public Node next;

        public Node(int val) {
            this.val = val;
        }

        public void printfList(Node head) {
            if (head == null) {
                return;
            }
            Node cur=head;
            Stack<Node> stack = new Stack<>();
            while (cur!=null){
                stack.push(cur);
                cur=cur.next;
            }
            while(!stack.empty()){
                System.out.println(stack.pop().val);
            }

        }
    }
}
